<template>
  <div id="app">
		<h1>在线翻译</h1>
		<h5 class="text-muted">简单 / 易用 / 便捷</h5>
		<TranslateForm v-on:formSubmit="translateText"></TranslateForm>
		<TranslateOutput v-text="translatedText"></TranslateOutput>
  </div>
</template>

<script>
import TranslateForm from './components/TranslateForm'
import TranslateOutput from './components/TranslateOutput'

export default {
  name: 'App',
  data:function(){
	return{
		translatedText:""
	}  
  },
  components: {
		TranslateForm,TranslateOutput
  },
	methods:{
		translateText:function(text,language){
			// alert(text+','+language);
			//trnsl.1.1.20190108T151512Z.b78b82b215b6d4f4.85ee5bba5da6a0fba668f445048a8a1a5e303054 
			this.$http.get('https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20190302T135944Z.16b581000c080bc7.1ff6be3f1735830d21d01e45b67d95cd068f0495&lang='+language+'&text='+text)
			.then((response)=>{
				// console.log(response.body.text[0]);
				this.translatedText=response.body.text[0];
			})
		}
	}
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
